package com.common.pullToRefresh;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.common.StarAppConst;
import com.common.utils.StarAppUtils;
import com.starappallcommon.R;

public class CommonListFooterView extends LinearLayout{
    private Drawable mProgressBarRes = null;
    private ProgressBar mProgressBar;
    public CommonListFooterView(Context context) {
        super(context);
        initView(context);
    }
    
    public CommonListFooterView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    /**
     *  自定义设置底部转圈资源
     * 
     * <br>Created 2014-8-21 下午3:48:20
     * @param d 转圈资源
     * @author        :  chenyw
     */
    public void setProgressBarRes(Drawable d){
        mProgressBarRes = d;
        if(mProgressBarRes != null && mProgressBar != null){
            mProgressBar.setIndeterminateDrawable(mProgressBarRes);
        }
    }
    
    public void initView(Context context){
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        LinearLayout moreView = (LinearLayout) inflater.inflate(R.layout.common_listview_footer,null);
        addView(moreView);
        moreView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
        mProgressBar = (ProgressBar)moreView.findViewById(R.id.foot_progress_bar);
        setViewTypeFace((TextView)moreView.findViewById(R.id.foot_text_view), false);
    }
    /**
     * 设置视图的字体
     * 
     * <br>
     * Created 2014-7-30 下午6:59:56
     * 
     * @param view
     *            视图对象
     * @param isBold
     *            是否粗体
     * @author : yefl
     */
    public static void setViewTypeFace(TextView view, boolean isBold) {
        if (view == null) {
            return;
        }
        StarAppUtils.setViewTypeFace(view, isBold);
//        view.setTypeface(StarAppConst.getInstance().getLTXTypeface());
//        if (isBold) {
//            view.getPaint().setFakeBoldText(true);
//        }
    }
}
